# Copyright [2011] [Ilya Rudakov]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django.test import TestCase
from job_manager.services.storage_service import *
from job_manager.views import create_feed_group, create_feed_group

LOG = logging.getLogger(__name__)

class SimpleTest(TestCase):
    pass

__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.

>>> 1 + 1 == 2
True
"""}

class StorageTest(TestCase):
    def testCreateStorage(self):
        """
            Manual test. Check creation yourself
        """
        feed_storage = create_feed_group(name="My Test Storage", description="Sample description")
        print feed_storage.id
        self.assertTrue(feed_storage.id > 0)

    def test_get_short_file_name(self):
        file = open("./job_manager/tests.py")
        short_name = get_short_file_name(file.name)
        file.close()

        self.assertEqual("tests.py", short_name)

    def test_handle_feed_file(self):
        file = open("./job_manager/tests.py")
        handle_feed_file(file, "./feed_storage/test.py")


